sid
05/12/2026, 2:50 PMjs {} compilation to my app. However, I have a class that asks for kotlin.time.Clock in its constructor. Obviously, when compiling, the compiler says: Exported declaration uses non-exportable parameter type 'Clock'
What workarounds are there to solve this? I thought about adding @JsExport.Ignore to the constructor, create another constructor with @JsExport and asks for a Double maybe and then assign it to my clock. I am not sure if that's the best how to
I have another <https://github.com/theodorosidmar/pubgkt/blob/chore/js/common/src/commonMain/kotlin/dev/pubgkt/RetryConfiguration.kt#L55|constructor asking for List<KClassout Throwable>> with the same problem. Not sure what to do herebroadway_lamb
05/12/2026, 2:58 PMObviously, when compiling, the compiler says:Actually, this is not obvious at all 🙂 Which Kotlin version are you using? I don't see anyExported declaration uses non-exportable parameter type 'Clock'
@JsExport annotations, so the question is why does the compiler treat your class as exported?sid
05/12/2026, 3:01 PMbroadway_lamb
05/12/2026, 3:09 PMI thought about addingThis looks like the correct workaround, I would go with it too. As for theto the constructor, create another constructor with@JsExport.Ignoreand asks for a@JsExportmaybe and then assign it to my clock.Double
Retry class, do you absolutely need to export the full constructor, including the retryOnExceptions parameter, to JS?
If no, you can add a secondary constructor that doesn't include this parameter:
@JsExport
public data class Retry @JsExport.Ignore constructor(
val maxRetries: Int,
val backoff: BackoffStrategy,
val retryOnExceptions: List<KClass<out Throwable>>,
) : RetryPolicy {
constructor(
maxRetries: Int = 5,
backoff: BackoffStrategy = NoBackoff,
) : this(maxRetries, backoff, emptyList())
override val enabled: Boolean = true
}sid
05/12/2026, 3:14 PMsid
05/12/2026, 4:23 PMpubgkt/common/src/commonMain/kotlin/dev/pubgkt/RetryConfiguration.kt:60:5 Exported declaration uses non-exportable return type 'List<KClass<out Throwable>>'.
It seems @JsExport.Ignore does not work properly with `data class`es `constructor`s.
I am going to need to come up with another solutionbroadway_lamb
05/12/2026, 4:25 PMretryOnExceptions should be marked separately:
@JsExport
public data class Retry @JsExport.Ignore constructor(
val maxRetries: Int = 5,
val backoff: BackoffStrategy = NoBackoff,
@JsExport.Ignore val retryOnExceptions: List<KClass<out Throwable>> = emptyList(),
) : RetryPolicy {
...
}sid
05/12/2026, 4:25 PMsid
05/12/2026, 4:25 PMsid
05/12/2026, 4:40 PMsid
05/12/2026, 4:58 PMExported declaration uses non-exportable return type 'List<KClass<out Throwable>>'
2. Exported declaration uses non-exportable parameter type 'List<KClass<out Throwable>>'broadway_lamb
05/12/2026, 5:01 PMsid
05/12/2026, 5:05 PMbroadway_lamb
05/12/2026, 5:11 PMcopy and componentN functions that are generated by the compiler for data classes and that still use the non-exported type. The warning message could definitely be improved.sid
05/12/2026, 5:12 PMkotlin { compilerOptions { allWarningsAsErrors = true } } (reference)sid
05/12/2026, 5:13 PMbroadway_lamb
05/12/2026, 5:16 PMRetry class a regular class instead of a data class. As far as I can tell, Retry is part of the public API of your library, and we don't recommend using data classes in public API: https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api
When you make Retry a regular class, you will have to explicitly define the equals, hashCode, toString, copy and componentN methods to preserve the behavior and source (and binary) compatibility.broadway_lamb
05/12/2026, 5:19 PMDo you still want/need me to raise the ticket/issue?Yes, please
sid
05/12/2026, 5:21 PMYes, pleaseSure. But how would you like me to write it? As an issue "`@JsExport.Ignore` does not work properly with `data class`es members" or "the compiler warning message could be better" or something else?
broadway_lamb
05/12/2026, 5:21 PMsid
05/12/2026, 5:35 PM• For Gradle problems, include a Gradle scan (How can I do this?) in a comment with`jetbrains-team`visibility.gradle build --scan
sid
05/12/2026, 5:35 PMsid
05/12/2026, 5:37 PMbroadway_lamb
05/12/2026, 5:39 PMsid
05/12/2026, 5:40 PMbroadway_lamb
05/12/2026, 5:44 PMsid
05/12/2026, 5:44 PM